package com.dgut.config;

import cn.dev33.satoken.stp.StpInterface;
import com.dgut.pojo.Role;
import com.dgut.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Component
public class StpInterfaceImpl implements StpInterface {
    @Autowired
    private RoleService roleService;
    @Override
    public List<String> getPermissionList(Object o, String s) {
        return null;
    }


    /**
     * 获取角色
     * @param o
     * @param s
     * @return
     */
    @Override
    public List<String> getRoleList(Object o, String s) {
        List<String> list = new ArrayList<>();
        Long id = Long.parseLong((String) o);
        List<Role> roleList = roleService.findAllById(id);

        for(Role r:roleList){
            list.add(r.getRole());
        }
        return list;
    }
}
